﻿using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyOCR.Picture
{
    public abstract class PictureHandle
    {
        /// <summary>
        /// 识别出的文字
        /// </summary>
        public string msg;

        /// <summary>
        /// 识别图片中的文字
        /// </summary>
        /// <param name="img">需要识别的图片</param>
        /// <returns>返回字符串</returns>
        public abstract string IdentifyImage(Image img);

        /// <summary>
        /// 返回MD5码
        /// </summary>
        /// <returns></returns>
        protected abstract string getSign();

        /// <summary>
        /// 灰度化图片
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        protected Bitmap GrayscaleImage(Image img)
        {
            Bitmap bitmap = new Bitmap(img);
            //Image<Gray, Byte> gray = new Image<Gray, byte>(bitmap);
            //var return_img = gray.CopyBlank();
            //CvInvoke.Threshold(gray, return_img, 100, 255, ThresholdType.Binary);

            ////Image img2 = return_img.Bitmap;
            ////System.Windows.Forms.Clipboard.SetImage(img2);
            //return return_img.Bitmap;
            return bitmap;
        }
    }
}
